import os
from pprint import pprint

import pandas as pd

class DateOperation:
    def __init__(self,filename):
        #从pandas读取文件
        # self.data=pd.read_csv(path)    #csv ,tsv ,txt
        #设置文件读取路径
        base_path = os.path.dirname(os.path.dirname(__file__)) + '\data'
        self.filepath=os.path.join(base_path,filename)
        #读取文件数据
        if filename.split('.')[-1] == 'csv':
            self.data=pd.read_csv(self.filepath)
        else:
            self.data=pd.read_excel(self.filepath)
        


    def get_data_to_dict(self):
        #[{},{},{}] 以列表字典
        return [self.data.loc[i] for i in self.data.index.values]

    def get_data_to_list(self):
        #[[],[],[]]  以列表列表
        return self.data.values.tolist()



if __name__ == '__main__':
    # 输入文件名，创建对象
    file='month.xlsx'
    data=DateOperation(file)
    print(data.get_data_to_list())

